<%@ page language="java" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<base href="<%=basePath%>">

	<title>CON-031: Production Control System Summary[Output]</title>
	
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="./css/custom.css">

</head>
  
<body>
	<f:view>
		<f:loadBundle var="bundle" basename="com.tpc.control.message.ResourceBundle"/>
		<h:form id="con031Form">
			<h:outputText value="Production Control System Summary" styleClass="headerText"/>	
			<h:commandButton action="back030" value="Back"/>
			<h:commandButton value="Download To Excel" actionListener="#{con030.downloadSummaryToExcel}"/>
			<rich:scrollableDataTable value="#{con030.reports}" var="item" width="1200px" height="550px" id="divisionSummaryTable" frozenColCount="1">
				<rich:column width="40px" styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="Division"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.division.division}"></h:outputText>
					<f:facet name="footer">
						<h:outputText value="Total" styleClass="footerSubject"/>
					</f:facet>
				</rich:column>
				<rich:column styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_order}"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.totalOrder}">
						<f:convertNumber pattern="#,##0"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalOrder}">
							<f:convertNumber pattern="#,##0"/>
						</h:outputText>
					</f:facet>
				</rich:column>
				<rich:column styleClass="textRight">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_order_amount}"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.totalOrderAmount}">
						<f:convertNumber pattern="#,##0.00"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalOrderAmount}">
							<f:convertNumber pattern="#,##0.00"/>
						</h:outputText>
					</f:facet>
				</rich:column>
				<rich:column width="120px" styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_complete}"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.totalComplete}">
						<f:convertNumber pattern="#,##0"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalComplete}">
							<f:convertNumber pattern="#,##0"/>
						</h:outputText>
					</f:facet>
				</rich:column>
				<rich:column width="120px" styleClass="textRight">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_complete_amount}"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.totalCompleteAmount}">
						<f:convertNumber pattern="#,##0.00"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalCompleteAmount}">
							<f:convertNumber pattern="#,##0.00"/>
						</h:outputText>
					</f:facet>
				</rich:column>
				<rich:column styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_remain}"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.totalRemain}">
						<f:convertNumber pattern="#,##0"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalRemain}">
							<f:convertNumber pattern="#,##0"/>
						</h:outputText>
					</f:facet>
				</rich:column>
				<rich:column styleClass="textRight">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_remain_amount}"></h:outputText>
					</f:facet>
					<h:outputText value="#{item.totalRemainAmount}">
						<f:convertNumber pattern="#,##0.00"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalRemainAmount}">
							<f:convertNumber pattern="#,##0.00"/>
						</h:outputText>
					</f:facet>
				</rich:column>
				<rich:column width="80px" styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="#{bundle.tot_overdue}"/>
					</f:facet>
					<h:outputText value="#{item.allTotalStatus}">
						<f:convertNumber pattern="#,##0"/>
					</h:outputText>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.allTotalStatus}">
							<f:convertNumber pattern="#,##0"/>
						</h:outputText>
					</f:facet>						
				</rich:column>	
				
				<rich:column width="80px" styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="#{con030.overDueStatusList[0].statusName}"/>
					</f:facet>
					<a4j:commandLink oncomplete="#{rich:component('greigePanel')}.show()" reRender="greigePanel" action="#{con030.resetGreigeSorting}">
						<h:outputText value="#{item.totalStatus[0]}">
							<f:converter converterId="statusConverter"/>
						</h:outputText>
						<f:setPropertyActionListener value="#{item.totalStatusSaleDetail[0]}" target="#{con030.selectGreigeOver}"/>
					</a4j:commandLink>
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalStatus[0]}">
							<f:convertNumber pattern="#,##0"/>
						</h:outputText>
					</f:facet>					
				</rich:column>
				<rich:column width="80px" styleClass="textCenter">
					<f:facet name="header">
						<h:outputText value="#{con030.overDueStatusList[1].statusName}"/>
					</f:facet>
					<a4j:commandLink oncomplete="#{rich:component('productionPanel')}.show()" reRender="productionPanel" action="#{con030.resetProductionSorting}">
						<h:outputText value="#{item.totalStatus[1]}">
							<f:converter converterId="statusConverter"/>
						</h:outputText>
						<f:setPropertyActionListener value="#{item.totalStatusDetail[1]}" target="#{con030.selectDyeOver}"/>
					</a4j:commandLink>					
					<f:facet name="footer">
						<h:outputText value="#{con030.totalLine.totalStatus[1]}">
							<f:convertNumber pattern="#,##0"/>
						</h:outputText>
					</f:facet>						
				</rich:column>				
			</rich:scrollableDataTable>		
			<rich:modalPanel id="greigePanel" autosized="false"
				keepVisualState="false" width="1200" height="600">
				<f:facet name="header">
					<h:outputText value="Greige Detail" />
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/images/modal/close.png"
							id="closeGreigelink" />
						<rich:componentControl for="greigePanel"
							attachTo="closeGreigelink" operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<a4j:outputPanel layout="block" styleClass="divScrollPopupCon021">
					<a4j:outputPanel layout="block" styleClass="divScroll">
						<rich:dataTable value="#{con030.selectGreigeOver}" 
									var="greige" id="greigeTable" sortMode="multi">
							<rich:column styleClass="textCenter" sortBy="#{greige.saleData.id.saleOrder}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select04}" />
								</f:facet>
								<h:outputText value="#{greige.saleData.id.saleOrder}" />
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{greige.saleData.id.saleItem}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select05}" />
								</f:facet>
								<h:outputText value="#{greige.saleData.id.saleItem}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select02}" />
								</f:facet>
								<h:outputText value="#{greige.saleData.customerName}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select12}" />
								</f:facet>
								<h:outputText value="#{greige.saleData.material}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select13}" />
								</f:facet>
								<h:outputText value="#{greige.commonData.designNoFg}" />
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{greige.saleData.dueDate}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select09}" />
								</f:facet>
								<h:outputText value="#{greige.saleData.dueDate}">
									<f:convertDateTime pattern="dd.MM.yyyy" locale="th_US"/>
								</h:outputText>
							</rich:column>
							<rich:column sortBy="#{greige.commonData.id.productionNo}">
								<f:facet name="header">
									<h:outputText value="Production No." />
								</f:facet>
								<h:outputText value="#{greige.commonData.id.productionNo}" />
							</rich:column>
							<rich:column sortBy="#{greige.commonData.plant.plantId}">
								<f:facet name="header">
									<h:outputText value="Plant" />
								</f:facet>
								<h:outputText value="#{greige.commonData.plant.plantId}" />
							</rich:column>
							<rich:column sortBy="#{greige.commonData.material}">
								<f:facet name="header">
									<h:outputText value="Greige Mat." />
								</f:facet>
								<h:outputText value="#{greige.commonData.material}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="Greige Design" />
								</f:facet>
								<h:outputText value="#{greige.commonData.designNoFg}" />
							</rich:column>
							<rich:column styleClass="textRight">
								<f:facet name="header">
									<h:outputText value="#{bundle.select15}" />
								</f:facet>
								<h:outputText value="#{greige.commonData.quantity}">
									<f:convertNumber pattern="#,##0.000"/>
								</h:outputText>
							</rich:column>
							<rich:column styleClass="textCenter">
								<f:facet name="header">
									<h:outputText value="#{bundle.select16}" />
								</f:facet>
								<h:outputText value="#{greige.commonData.uom}" />
							</rich:column>
							<rich:column styleClass="textCenter">
								<f:facet name="header">
									<h:outputText value="Basic Start Date" />
								</f:facet>
								<h:outputText value="#{greige.commonData.basicStartDate}">
									<f:convertDateTime pattern="dd.MM.yyyy" locale="th_US"/>
								</h:outputText>
							</rich:column>
							<rich:column styleClass="textCenter">
								<f:facet name="header">
									<h:outputText value="Basic Finish Date" />
								</f:facet>
								<h:outputText value="#{greige.commonData.basicFinishDate}">
									<f:convertDateTime pattern="dd.MM.yyyy" locale="th_US"/>
								</h:outputText>
							</rich:column>		
							<rich:column styleClass="textRight">
								<f:facet name="header">
									<h:outputText value="#{bundle.select38}" />
								</f:facet>
								<h:outputText value="#{greige.commonData.finishGoods}">
									<f:convertNumber pattern="#,##0.000"/>
								</h:outputText>
							</rich:column>	
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.remark}" />
								</f:facet>
								<h:outputText value="#{greige.planGreige.remark}" />
							</rich:column>					
						</rich:dataTable>				
					</a4j:outputPanel>
				</a4j:outputPanel>
			</rich:modalPanel>
			<rich:modalPanel id="productionPanel" autosized="false"
				keepVisualState="false" width="1200" height="600">
				<f:facet name="header">
					<h:outputText value="Production Detail" />
				</f:facet>
				<f:facet name="controls">
					<h:panelGroup>
						<h:graphicImage value="/images/modal/close.png"
							id="closeProductionlink" />
						<rich:componentControl for="productionPanel"
							attachTo="closeProductionlink" operation="hide" event="onclick" />
					</h:panelGroup>
				</f:facet>
				<a4j:outputPanel layout="block" styleClass="divScrollPopupCon021">
					<a4j:outputPanel layout="block" styleClass="divScroll">
						<rich:dataTable value="#{con030.selectDyeOver}" 
									var="production" id="productionTable" sortMode="multi">
							<rich:column styleClass="textCenter">
								<f:facet name="header">
									<h:outputText value="Status" />
								</f:facet>
								<h:graphicImage value="/images/status/#{production.colorStatus}.gif"></h:graphicImage>
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{production.saleData.id.saleOrder}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select04}" />
								</f:facet>
								<h:outputText value="#{production.saleData.id.saleOrder}" />
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{production.saleData.id.saleItem}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select05}" />
								</f:facet>
								<h:outputText value="#{production.saleData.id.saleItem}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select02}" />
								</f:facet>
								<h:outputText value="#{production.customerName}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select03}" />
								</f:facet>
								<h:outputText value="#{production.customerPoNo}" />
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{production.distrChannel}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select06}" />
								</f:facet>
								<h:outputText value="#{production.distrChannel}" />
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{production.dueDate}">
								<f:facet name="header">
									<h:outputText value="#{bundle.select09}" />
								</f:facet>
								<h:outputText value="#{production.dueDate}">
									<f:convertDateTime pattern="dd.MM.yyyy" locale="th_US"/>
								</h:outputText>
							</rich:column>
							<rich:column sortBy="#{production.id.productionNo}">
								<f:facet name="header">
									<h:outputText value="Production No." />
								</f:facet>
								<h:outputText value="#{production.id.productionNo}" />
							</rich:column>
							<rich:column styleClass="textCenter" sortBy="#{production.plant.plantId}">
								<f:facet name="header">
									<h:outputText value="plant" />
								</f:facet>
								<h:outputText value="#{production.plant.plantId}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select12}" />
								</f:facet>
								<h:outputText value="#{production.material}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select13}" />
								</f:facet>
								<h:outputText value="#{production.designNoFg}" />
							</rich:column>
							<rich:column styleClass="textRight">
								<f:facet name="header">
									<h:outputText value="#{bundle.select15}" />
								</f:facet>
								<h:outputText value="#{production.quantity}">
									<f:convertNumber pattern="#,##0.000"/>
								</h:outputText>
							</rich:column>
							<rich:column styleClass="textCenter">
								<f:facet name="header">
									<h:outputText value="#{bundle.select16}" />
								</f:facet>
								<h:outputText value="#{production.uom}" />
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select35}" />
								</f:facet>
								<h:outputText value="#{production.currentOperation}" />
							</rich:column>
							<rich:column styleClass="textRight">
								<f:facet name="header">
									<h:outputText value="#{bundle.select38}" />
								</f:facet>
								<h:outputText value="#{production.finishGoods}">
									<f:convertNumber pattern="#,##0.000"/>
								</h:outputText>
							</rich:column>
							<rich:column>
								<f:facet name="header">
									<h:outputText value="#{bundle.select36}" />
								</f:facet>
								<h:outputText value="#{production.userStatus}" />
							</rich:column>
						</rich:dataTable>			
					</a4j:outputPanel>
					<rich:simpleTogglePanel style="width: 400px" switchType="client" opened="false">
						<f:facet name="header">
							<h:outputText value="Status Information" />
						</f:facet>
						<h:panelGrid columns="2" style="font-size: 11px">
							<h:graphicImage value="/images/status/red.gif" />
							<h:outputText value="#{bundle.warning01}" />
							<h:graphicImage value="/images/status/orange.gif" />
							<h:outputText value="#{bundle.warning02}" />
							<h:graphicImage value="/images/status/yellow.gif" />
							<h:outputText value="#{bundle.warning03}" />
							<h:graphicImage value="/images/status/pink.gif" />
							<h:outputText value="#{bundle.warning04}" />
							<h:graphicImage value="/images/status/violet.gif" />
							<h:outputText value="#{bundle.warning05}" />
							<h:graphicImage value="/images/status/green.gif" />
							<h:outputText value="#{bundle.warning06}" />
							<h:graphicImage value="/images/status/white.gif" />
							<h:outputText value="#{bundle.warning07}" />
						</h:panelGrid>
					</rich:simpleTogglePanel>
				</a4j:outputPanel>
			</rich:modalPanel>				
		</h:form>
	</f:view>
</body>
</html>